function signin(){
    $('#signinForm').data('formValidation').validate();
}

$(document).ready(function() {
    $('#signinForm')
        .formValidation({
            message: '输入的值无效',
            icon: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                user: {
                    message: '无效的用户名',
                    validators: {
                        notEmpty: {
                            message: '用户名不能为空'
                        },
                        stringLength: {
                            min: 6,
                            max: 16,
                            message: '用户名的长度在6-16之间(包括6/16)'
                        },
                        regexp: {
                            regexp: /^[a-zA-Z0-9_\.]+$/,
                            message: '用户名只能由字母、数字、点和下划线组成'
                        }
                    }
                },
                password: {
                    validators: {
                        notEmpty: {
                            message: '密码不能为空'
                        }
                    }
                }
            }
        })
        .on('success.form.fv', function(e) {
            e.preventDefault();
            $.ajax({
                url: '/signin',
                type: 'POST',
                data: $('#signinForm').serialize(),
                success: function (data) {
                    if(data.status == 200){
                        $("#signinForm").data('formValidation').resetForm(true);//重置表单
                        show_alert(data.message,function(){
                            jump_page('/main');
                        });
                    }else{
                        alert(data.message);
                    }
                }
            });
        });
});